package cn.zktr.Personnel.model.service.zhouyongcong;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.zktr.Personnel.model.dao.ouyangpeng.RetRcdDao;
import cn.zktr.Personnel.model.dao.ouyangpeng.RetWaltDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.AuditDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.AuditShlxDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.AuditTabDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.AuditZdDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsActDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsDeptDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsDisDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsEmpDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsHContDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsLxfsDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsPesDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsPotDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsSexDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsStmDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsYBunDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsYGDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsYQDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsYYtypDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsZJnxxDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsZhijiDao;
import cn.zktr.Personnel.model.pojos.PerAudit;
import cn.zktr.Personnel.model.pojos.PerAuditShlx;
import cn.zktr.Personnel.model.pojos.PerAuditTab;
import cn.zktr.Personnel.model.pojos.PerAuditZd;
import cn.zktr.Personnel.model.pojos.PerPmsAct;
import cn.zktr.Personnel.model.pojos.PerPmsDept;
import cn.zktr.Personnel.model.pojos.PerPmsDis;
import cn.zktr.Personnel.model.pojos.PerPmsEmp;
import cn.zktr.Personnel.model.pojos.PerPmsHCont;
import cn.zktr.Personnel.model.pojos.PerPmsLxfs;
import cn.zktr.Personnel.model.pojos.PerPmsPes;
import cn.zktr.Personnel.model.pojos.PerPmsPot;
import cn.zktr.Personnel.model.pojos.PerPmsSex;
import cn.zktr.Personnel.model.pojos.PerPmsStm;
import cn.zktr.Personnel.model.pojos.PerPmsYBun;
import cn.zktr.Personnel.model.pojos.PerPmsYG;
import cn.zktr.Personnel.model.pojos.PerPmsYQ;
import cn.zktr.Personnel.model.pojos.PerPmsYYtyp;
import cn.zktr.Personnel.model.pojos.PerPmsZJnxx;
import cn.zktr.Personnel.model.pojos.PerPmsZhiji;
import cn.zktr.Personnel.model.pojos.PerRetRcd;
import cn.zktr.Personnel.model.pojos.PerRetWAlt;

@Service
@Transactional(rollbackFor=Exception.class)
public class findService {
	@Autowired
	private PmsEmpDao ped;
	@Autowired
	private PmsDeptDao pdd;
	@Autowired
	private PmsPotDao ppd;
	@Autowired
	private PmsYYtypDao pyyd;
	@Autowired
	private PmsYBunDao pybd;
	@Autowired
	private PmsYQDao pqd;
	@Autowired
	private PmsYGDao pgd;
	@Autowired
	private PmsZhijiDao pzd;
	@Autowired
	private PmsZJnxxDao pzjd;
	@Autowired
	private AuditTabDao atd;
	@Autowired
	private AuditZdDao azd;
	@Autowired
	private AuditDao ad;
	@Autowired
	private AuditShlxDao asd;
	@Autowired
	private PmsStmDao psd;
	@Autowired
	private RetWaltDao rwd;
	@Autowired
	private PmsPesDao pped;
	@Autowired
	private PmsSexDao psed;
	@Autowired
	private PmsLxfsDao pld;
	@Autowired
	private PmsActDao pad;
	@Autowired
	private PmsDisDao pdid;
	@Autowired
	private RetRcdDao rrd;
	@Autowired
	private PmsHContDao phcd;
	
	public PerPmsHCont findHContid(Integer id) {
		return phcd.findById(id).get();
	}
	
	public PerRetRcd findRcdid(Integer id) {
		return rrd.findById(id).get();
	}
	
	public List<PerRetRcd> findAllRcd() {
		List<PerRetRcd> list = (List<PerRetRcd>) rrd.findAll();
		for(int i=0;list.size()>i;i++) {
			if(!list.get(i).getRcdstat().equals("1")) {
				list.remove(i);
				i--;
			}
		}
		return list;
	}
	
	public PerPmsDis findDisid(Integer id) {
		return pdid.findById(id).get();
	}
	
	public List<PerPmsDis> findAllDis() {
		List<PerPmsDis> list = (List<PerPmsDis>) pdid.findAll();
		for(int i=0;list.size()>i;i++) {
			if(list.get(i).getDiszt().equals("复职")||list.get(i).getDiszt().equals("待审核")) {
				list.remove(i);
				i--;
			}
		}
		return list;
	}
	
	public PerPmsAct findActid(Integer id) {
		return pad.findById(id).get();
	}
	
	public List<PerPmsAct> findAllAct() {
		return (List<PerPmsAct>) pad.findAll();
	}
	
	public List<PerPmsLxfs> findAllLxfs() {
		return (List<PerPmsLxfs>) pld.findAll();
	}
	public PerPmsLxfs findLxfsid(Integer id) {
		return pld.findById(id).get();
	}
	
	public List<PerPmsSex> findAllSex() {
		return (List<PerPmsSex>) psed.findAll();
	}
	
	public List<PerPmsPes> findAllPes() {
		return (List<PerPmsPes>) pped.findAll();
	}
	
	public PerPmsPes findPesid(Integer id) {
		return pped.findById(id).get();
	}
	
	public PerPmsStm findStmid(Integer id) {
		return psd.findById(id).get();
	}
	
	public PerRetWAlt findWaltid(Integer id) {
		return rwd.findById(id).get();
	}
	
	public PerAuditShlx findShlxid(Integer id) {
		return asd.findById(id).get();
	}
	
	public List<PerAudit> findAllAudit() {
		return (List<PerAudit>) ad.findAll();
	}
	
	public PerAudit findAuditid(Integer id) {
		return ad.findById(id).get();
	}
	
	public List<PerAudit> findAllAuditlenght(Integer id) {
		List<PerAudit> list = (List<PerAudit>) ad.findByperAuditShlx1(findShlxid(id));
		for(int i=0;list.size()>i;i++) {
			if(list.get(i).getAuditjg().equals("已通过")) {
				list.remove(i);
				i--;
			}
		}
		return list;
	}
	
	public List<PerAuditTab> findAllTab() {
		return (List<PerAuditTab>) atd.findAll();
	}
	
	public List<PerAuditZd> findAllZd() {
		return (List<PerAuditZd>) azd.findAll();
	}
	
	public List<PerPmsZJnxx> findAllZJnxx() {
		return (List<PerPmsZJnxx>) pzjd.findAll();
	}
	
	public PerPmsZJnxx findZJnxxid(Integer id) {
		return pzjd.findById(id).get();
	}
	
	public PerPmsYG findYGid(Integer id) {
		return pgd.findById(id).get();
	}
	
	public PerPmsYQ findYQid(Integer id) {
		return pqd.findById(id).get();
	}
	
	public PerPmsYBun findBunid(Integer id) {
		return pybd.findById(id).get();
	}
	
	public PerPmsYYtyp findYYtypid(Integer id) {
		return pyyd.findById(id).get();
	}
	
	public List<PerPmsPot> findAllPot() {
		return (List<PerPmsPot>) ppd.findAll();
	}
	
	public PerPmsPot findPotid(Integer id) {
		return ppd.findById(id).get();
	}
	
	public List<PerPmsDept> findAllDept() {
		return (List<PerPmsDept>) pdd.findAll();
	}
	
	public PerPmsDept findDeptid(Integer id) {
		return pdd.findById(id).get();
	}
	
	public List<PerPmsEmp> findAllEmp(){
		List<PerPmsEmp> list = (List<PerPmsEmp>) ped.findAll();
		for(int i=0;list.size()>i;i++) {
			if(list.get(i).getPerPmsStms().size()==0) {
				list.remove(i);
				i--;
			}
		}
		return list;
	}
	
	public PerPmsEmp findEmpid(Integer id) {
		return ped.findById(id).get();
	}

	public PerPmsZhiji findZhiji(Integer id) {
		return pzd.findById(id).get();
	}
	
}
